﻿using SqlSugar;

namespace Infratructure
{
    /// <summary>
    /// 仓储接口
    /// </summary>
    /// <typeparam name="T"></typeparam>

        public interface IRepository<T>
        {
            /// <summary>
            /// 查询某条数据
            /// </summary>
            /// <param name="id">主键</param>
            /// <returns>数据</returns>
            Task<T?> GetByIdAsync(long id);
            /// <summary>
            /// 添加某条数据
            /// </summary>
            /// <param name="id">主键</param>
            /// <returns>影响行数</returns>

            Task<int> AddAsync(T t);
            /// <summary>
            /// 修改某条数据
            /// </summary>
            /// <param name="t">修改后的数据</param>
            /// <returns>影响行数</returns>
            Task<int> UpdateAsync(T t);
            /// <summary>
            /// 删除某条数据
            /// </summary>
            /// <param name="id">主键</param>
            /// <returns>影响行数</returns>
            Task<int> DeleteAsync(long id);
            /// <summary>
            /// 获取列表数据
            /// </summary>
            /// <returns></returns>
            ISugarQueryable<T> GetAll();
            /// <summary>
            /// 添加多条数据
            /// </summary>
            /// <param name="id">主键</param>
            /// <returns>影响行数</returns>

            Task<int> AddRangeAsync(List<T> ts);
        /// <summary>
        /// 修改多条数据
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns>影响行数</returns>

        Task<int> UpdateRangeAsync(List<T> ts);
    }
}
